package com.tentative.competition.web.controller.schedule.client;

import com.tentative.competition.common.annotation.Anonymous;
import com.tentative.competition.common.core.controller.BaseController;
import com.tentative.competition.common.core.domain.AjaxResult;
import com.tentative.competition.schedule.service.ScheduleAdminService;
import com.tentative.competition.schedule.service.ScheduleWorksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther: Smile Huang
 * @date: 2023/6/26 20:46
 * @desc:
 * @version: 2.0
 */
@Api(tags = "client-往届作品")
@RestController
@RequestMapping("/client/previous")
public class PreviousWorksController extends BaseController {

    @Autowired
    private ScheduleWorksService worksService;

    @Autowired
    private ScheduleAdminService scheduleAdminService;

    @ApiImplicitParams({
            @ApiImplicitParam(name = "worksName", value = "作品名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "scheduleId", value = "赛程ID", dataType = "Long", dataTypeClass = Long.class,required = true),
    })
    @ApiOperation("根据赛程获取作品信息")
    @GetMapping(value = "/schedule-works")
    @Anonymous
    public AjaxResult getScheduleWorks(@RequestParam(value = "worksName") String worksName,
                                          @RequestParam(value = "scheduleId") Long scheduleId) {
        return success(worksService.getScheduleWorks(worksName,scheduleId));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "scheduleId", value = "赛程ID", dataType = "Long", dataTypeClass = Long.class),
    })
    @ApiOperation("获取除当前进行的赛程之外的赛程数据（k-y)")
    @GetMapping(value = "/schedule-pullDown/{scheduleId}")
    @Anonymous
    public AjaxResult getSchedulePullDown(@PathVariable("scheduleId") Long scheduleId) {
        return success(scheduleAdminService.getSchedulePullDown(scheduleId));
    }
}
